package cn.yh.shop.admin.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.yh.shop.admin.dao.RoleDao;
import cn.yh.shop.admin.model.Role;
import cn.yh.shop.admin.service.IAdminRoleService;
import cn.yh.shop.admin.service.IRoleMenuService;
import cn.yh.shop.admin.service.IRoleService;

/**
 * @Description:TODO
 * @author:"许荣斐"
 * @time:2016年12月16日 下午6:21:28
 */
@Service("roleService")
public class RoleServiceImpl implements IRoleService {

	@Autowired
	private RoleDao roleDao;
	@Autowired
	private IRoleMenuService roleMenuService;
	@Autowired
	private IAdminRoleService adminRoleService;

	@Override
	public Role queryObject(Integer roleId) {
		return roleDao.queryObject(roleId);
	}

	@Override
	public List<Role> queryList(Map<String, Object> map) {
		return roleDao.queryList(map);
	}

	@Override
	public int queryTotal(Map<String, Object> map) {
		return roleDao.queryTotal(map);
	}

	@Override
	@Transactional
	public void save(Role role) {
		roleDao.save(role);
		
		//保存角色与菜单关系
		roleMenuService.saveOrUpdate(role.getId(), role.getMenuIdList());
	}

	@Override
	@Transactional
	public void update(Role role) {
		roleDao.update(role);
		
		//更新角色与菜单关系
		roleMenuService.saveOrUpdate(role.getId(), role.getMenuIdList());
	}

	@Override
	@Transactional
	public void deleteBatch(Integer[] roleIds) {
		roleDao.deleteBatch(roleIds);
	}

	@Override
	public List<Role> selectAll() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int delOneRole(Integer id) {
		// TODO Auto-generated method stub
		return 0;
	}
	
	

	
}
